#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
double r[5];
int cnt[]={1,2,3,5};
double dp[55];
int main() {
    int n;
    cin>>n;
    dp[0]=1.0;
    for (int i=0; i<4; ++i) cin>>r[cnt[i]], r[cnt[i]]=pow(1+r[cnt[i]], cnt[i]);
    for (int i=1; i<=n; ++i) {
        for (int j=0; j<4; ++j) {
            if (cnt[j]<=i && dp[i-cnt[j]]*r[cnt[j]] > dp[i]) dp[i] = dp[i-cnt[j]]*r[cnt[j]];
        }
    }
    printf("%.5lf\n", dp[n]);
    return 0;
}
